USE [NGroup.VTL.DB]
GO

/****** Object:  StoredProcedure [dbo].[UpdateUser]    Script Date: 12/30/2013 22:32:32 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UpdateUser]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[UpdateUser]
GO

USE [NGroup.VTL.DB]
GO

/****** Object:  StoredProcedure [dbo].[UpdateUser]    Script Date: 12/30/2013 22:32:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO




-- =============================================
-- Author:		Nguyen Vu Nam
-- Create date: 20131218
-- Description:	Update User
-- =============================================
CREATE PROCEDURE [dbo].[UpdateUser]
	
	@Username			NVARCHAR(50),
	@Password			NVARCHAR(200),
	@UserAlias			NVARCHAR(100) = NULL,	
	@LastUpdatedAt datetime,
	@LastUpdatedBy nvarchar(50),
	@Rowcount			INT = -1 OUTPUT

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	BEGIN
	UPDATE [NGroup.VTL.DB].[dbo].[Users]
	   SET 
		[UserAlias] = @UserAlias
		  ,[Password] = @Password
		  ,[LastUpdatedAt] = @LastUpdatedAt
		  ,[LastUpdatedBy] = @LastUpdatedBy
	 WHERE [Username] = @Username
	 END
	 SELECT @Rowcount = @@ROWCOUNT
END




GO

